package com.example.find_module;

import com.example.common.databus.LiveDataBus;
import com.example.common.mvvm.BaseEntity;
import com.example.common.mvvm.viewmodel.BaseViewModel;

import java.util.List;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;

public class FindTabViewModel extends BaseViewModel<FindTabRepository> {
    LiveDataBus<List<CollectEntity.DataBean.CollectData>>collectList=new LiveDataBus<>();
    @Override
    public void onResult(BaseEntity entity) {
        if (entity instanceof CollectEntity){
            CollectEntity collectEntity= (CollectEntity) entity;
            List<CollectEntity.DataBean.CollectData> data = collectEntity.data.data;
            collectList.postValue(data);
        }
    }

    @Override
    protected void initData() {
        repository.requestCollectData()
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(this);
    }
}
